import frida
import sys


def on_message(message, data):
    if message['type'] =='send':
        print("[*] {0}".format(message['payload']))
    else:
        print(message)

process = frida.get_usb_device().attach('分享合伙人')
# 从文件中读取 JavaScript 代码
with open('hook.js', 'r', encoding='utf-8') as file:
    jscode = file.read()

try:
    script = process.create_script(jscode)
    script.on('message', on_message)
    print('[*] Running CTF')
    script.load()
    # 恢复目标应用程序的执行
    sys.stdin.read()
except KeyboardInterrupt:
    sys.exit(0)